package com.example.electronicmall.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.example.electronicmall.entity.ItemEntity;
import com.example.electronicmall.entity.ShopEntity;
import com.example.electronicmall.service.ShopService;
import com.example.electronicmall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author mwh
 * @email 1062966353@qq.com
 * @date 2022-12-02 14:48:53
 */
@RestController
@RequestMapping("shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    @PostMapping("/save")
    public R createShop(Integer businessId, String shopName, String shopAddress){
        shopService.createShop(businessId, shopName, shopAddress);
        return R.ok().setData("门店创建成功");
    }

    @PostMapping("/queryShopByBusinessId")
    public List<ShopEntity> queryShopByBusinessId(Integer businessId){
        return shopService.queryShopByBusinessId(businessId);
    }

    @GetMapping("/shopList")
    public List<ShopEntity> listAllShops(){
        return shopService.listAllShops();
    }

    @PostMapping("/listShopsByBusinessId")
    public List<ShopEntity> listShopsByBusinessId(Integer businessId){
        return shopService.listShopsByBusinessId(businessId);
    }

}
